package com.cssw.fyzb.web.controller;


import com.cssw.fyzb.base.web.context.UserContext;
import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.web.service.CmfAnchorService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@ApiModel("主播相关接口")
@RestController
@RequestMapping("/anchor")
public class CmfAnchorController {

    @Autowired
    CmfAnchorService cmfAnchorService;

    @ApiOperation(value = "主播列表", response = AjaxPage.class)
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "string", required = true),
            @ApiImplicitParam(name = "limit", value = "每页条数", paramType = "query", dataType = "string", required = true),
            @ApiImplicitParam(name = "search", value = "昵称", paramType = "query", dataType = "string", required = false),
    })
    public AjaxPage list(int page, int limit,String search) {
        return cmfAnchorService.list(page, limit,search);
    }

    @ApiOperation(value = "停播和解封", response = AjaxData.class)
    @RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
    public AjaxData updateStatus(@RequestBody Map<String,String> param) {
        return cmfAnchorService.updateStatus(Long.parseLong(param.get("anchorId")),param.get("status"),UserContext.getUserId());
    }
}
